From: Richard M. Stallman Date: Sat, 14 May 1994 06:34:26 +0000 (+0000) Subject: (Fcopy_file): Close output before setting its times. X-Git-Tag: archive/raspbian/1%29.2+1-2+rpi1^2~5^2~91569 X-Git-Url: https://dgit.raspbian.org/%22http:/www.example.com/cgi/%22https:/www.github.com/%22bookmarks:///%22http:/www.example.com/cgi/%22https:/www.github.com/%22bookmarks:/?a=commitdiff_plain;h=5acac34e2a01eb811c6e532fa580d8208064a7d3;p=emacs.git (Fcopy_file): Close output before setting its times. Close both before discarding the unwind protects. --- diff --git a/src/fileio.c b/src/fileio.c index 0df30ef2c43..4f1ff5bf69e 100644 --- a/src/fileio.c +++ b/src/fileio.c @@ -1803,6 +1803,10 @@ A prefix arg makes KEEP-TIME non-nil.") report_file_error ("I/O error", Fcons (newname, Qnil)); immediate_quit = 0; + /* Closing the output clobbers the file times on some systems. */ + if (close (ofd) < 0) + report_file_error ("I/O error", Fcons (newname, Qnil)); + if (input_file_statable_p) { if (!NILP (keep_date)) @@ -1818,13 +1822,11 @@ A prefix arg makes KEEP-TIME non-nil.") chmod (XSTRING (newname)->data, st.st_mode & 07777); } + close (ifd); + /* Discard the unwind protects. */ specpdl_ptr = specpdl + count; - close (ifd); - if (close (ofd) < 0) - report_file_error ("I/O error", Fcons (newname, Qnil)); - UNGCPRO; return Qnil; }